import 'package:flutter/material.dart';
import 'package:flutter_base/config/app_color.dart';
import 'package:flutter_base/utils/loading/loading_animation.dart';
import 'package:flutter_base/widgets/image/auto_image.dart';
import 'package:transparent_pointer/transparent_pointer.dart';

import '../../../generated/assets.dart';
import '../empty/empty_view.dart';

mixin BaseLoadingMixin on Widget {
  Widget buildLoading() {
    return Center(
      child: Padding(
        padding: const EdgeInsets.only(bottom: 50),
        child: Column(
          mainAxisSize: MainAxisSize.min,
          mainAxisAlignment: MainAxisAlignment.center,
          children: [
            // const AutoImage(Assets.hudLoading, width: 40),
            const LoadingAnimation(color: AppColor.primary),
            const SizedBox(height: 8),
            Text("加载中…", style: TextStyle(fontSize: 12, color: Colors.white.withOpacity(0.6))),
          ],
        ),
      ),
    );
  }

  Widget buildNoNetwork() {
    return TransparentPointer(
      child: GestureDetector(
        onTap: clickToRefresh,
        child: EmptyView.networkView(),
      ),
    );
  }

  Widget buildError({String? image, String? message}) {
    return TransparentPointer(
      child: GestureDetector(
        onTap: clickToRefresh,
        child: Center(
          child: EmptyView(
            image: image,
            message: message,
          ),
        ),
      ),
    );
  }

  Widget buildEmpty({String? image, String? message}) {
    return TransparentPointer(
      child: GestureDetector(
        onTap: clickToRefresh,
        child: Center(
          child: EmptyView(
            image: image,
            message: message,
          ),
        ),
      ),
    );
  }

  void clickToRefresh() {}
}
